<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends PublicController {
    public function index(){
        $this->display();
    }

    public function reg(){
        $this->display();
    }

    public function code(){
    	$config =    array(
		    'fontSize'    =>    30,    // 验证码字体大小
		    'length'      =>    4,     // 验证码位数
		    'useNoise'    =>    false, // 关闭验证码杂点
		);

		$Verify =     new \Think\Verify($config);
		$Verify->codeSet = '0123456789'; 
		$Verify->entry();
    }

    public function get_sms(){
        $mobile = $_POST['mobile'];
        $code = $_POST['code'];
        $check = $this->check_verify($code);
        if ($check == ture) {
            $da['success'] = 1;
        }else{
            $da['success'] = 0;
            $da['res'] = '验证码错误！';
        }
        ret($da);
    }

    public function check_verify($code, $id = ''){
        $verify = new \Think\Verify();
        return $verify->check($code, $id);
    }

    public function do_login(){
        $_SESSION['user_id'] = 1;
    	$this->success('登陆成功！',U('Mine/index'));
    }

    public function do_reg(){
        $_SESSION['user_id'] = 1;
        $this->success('注册成功，已帮您自动登录！',U('Mine/index'));
    }


}